//
//
//
//
//
//
//
//
//
//
//
//
import {isPc, getColor} from '../utils'
export default {
name: 'mu-chip',
props: {
showDelete: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
deleteIconClass: {
type: [Array, String, Object]
},
backgroundColor: {
type: String
},
color: {
type: String
}
},
data () {
return {
focus: false,
hover: false
}
},
computed: {
classNames () {
if (this.disabled) return null
return this.focus ? ['hover', 'active'] : this.hover ? ['hover'] : null
},
style () {
return {
'background-color': getColor(this.backgroundColor),
'color': getColor(this.color)
}
}
},
methods: {
onMouseenter () {
if (isPc()) this.hover = true
},
onMouseleave () {
if (isPc()) this.hover = false
},
onMousedown () {
this.focus = true
},
onMouseup () {
this.focus = false
},
onTouchstart () {
this.focus = true
},
onTouchend () {
this.focus = false
},
handleDelete () {
this.$emit('delete')
},
handleClick () {
if (!this.disabled) this.$emit('click')
}
}
}
|